﻿//通用上传图片方法2019
function uploadImage(callback, isMultiple) {
	var file;
	var url = getbaseurl("/file/upfiles.do");
	var form = $('<form action="' + url + '" method="post"></form>');
	file = $('<input type="file" accept="image/*;" name="file" style="display:none"/>');
	$('body').append(form);
	$(form).append(file);
	file.bind('change', function() {
		form.submit();
	});
	if (isMultiple) {
		file.attr("multiple", "multiple");
	}
	form.ajaxForm({
		beforeSubmit : function() {
		},
		success : function(data) {
			$("#loading").fadeOut();
			if (!data.resultData) {
				alert(data.message);
			} else if (callback != null) {
				callback(data);
			}
			form.remove();
		},
		error : function() {
			$("#loading").fadeOut();
			alert("上传失败");
			form.remove();
		}
	});
	file.click();
}
